package com.changy.ai_tutor_for_dm.service.impl;

import com.changy.ai_tutor_for_dm.entity.Tag;
import com.changy.ai_tutor_for_dm.mapper.TagsMapper;
import com.changy.ai_tutor_for_dm.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TagServiceImpl implements TagService {

    @Autowired
    private TagsMapper tagsMapper;

    /**
     * 获取所有二级标签列表
     * @param category 标签分类
     * @return category下的2级标签列表
     */
    @Override
    public List<Tag> getTags(String category) {
        List<Tag> tags = tagsMapper.getTags(category);
        return tags;
    }

    /**
     * 添加标签
     * @param tag 待添加的标签对象
     */
    @Override
    public void addTag(Tag tag) {
        tagsMapper.insert(tag);
    }

    /**
     * 删除标签
     * @param id 待删除的标签ID
     */
    @Override
    public void deleteTag(Integer id) {
        tagsMapper.delete(id);
    }

    /**
     * 修改标签
     * @param tag 待修改的标签对象
     */
    @Override
    public void updateTag(Tag tag) {
        tagsMapper.update(tag);
    }


}
